package com.combetter.changxing.fragment;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.combetter.changxing.R;
import com.combetter.changxing.base.BaseFragment;
import com.combetter.changxing.utils.ToastUtils;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author Vany Liu
 * e-mail liu1281781414@outlook.com
 * Created ${date} ${time}
 * description :首页Fragment
 **/
public class HomeFragment extends BaseFragment {
    @Bind(R.id.tv_title_name)
    TextView tvTitleName;
    @Bind(R.id.iv_back)
    ImageView ivBack;
    @Bind(R.id.iv_right)
    ImageView ivRight;
    @Bind(R.id.iv_sy_add)
    ImageView ivSyAdd;
    @Bind(R.id.tv_wpp)
    TextView tvWpp;
    @Bind(R.id.rl_not_add)
    RelativeLayout rlNotAdd;
    @Bind(R.id.sy_bg)
    ImageView syBg;
    @Bind(R.id.tv_sy_time)
    TextView tvSyTime;
    @Bind(R.id.view_sy1)
    View viewSy1;
    @Bind(R.id.tv_sy_time_num)
    TextView tvSyTimeNum;
    @Bind(R.id.tv1)
    TextView tv1;
    @Bind(R.id.tv2)
    TextView tv2;
    @Bind(R.id.tv_sy_cxsl)
    TextView tvSyCxsl;
    @Bind(R.id.tv_sy_jhzs)
    TextView tvSyJhzs;
    @Bind(R.id.rv_sy_cxxq)
    RecyclerView rvSyCxxq;
    @Bind(R.id.actionbar)
    Toolbar actionbar;
    @Bind(R.id.iv_sy_smoke)
    ImageView ivSySmoke;
    @Bind(R.id.tv_sy_smoke)
    TextView tvSySmoke;
    @Bind(R.id.iv_suo)
    ImageView ivSuo;
    @Bind(R.id.tv_pp)
    TextView tvPp;
    @Bind(R.id.tv_xh)
    TextView tvXh;
    @Bind(R.id.tv_pp_name)
    TextView tvPpName;
    @Bind(R.id.tv_xh_name)
    TextView tvXhName;
    @Bind(R.id.tv_sy1)
    TextView tvSy1;
    @Bind(R.id.rl_sy_add)
    RelativeLayout rlSyAdd;

    @Override
    protected int layoutId() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initViews(View view) {
        tvTitleName.setText("首页");
        ivBack.setVisibility(View.GONE);
    }


    @Override
    protected void loadData() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.iv_right, R.id.iv_sy_add})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_right:
                ToastUtils.normal("分享暂未开放");
                break;
            case R.id.iv_sy_add:
                //模拟加载数据的情况
                showNetProgessDialog("正在连接设备...", false);
                ivSyAdd.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (ivSyAdd != null) {
                            rlNotAdd.setVisibility(View.GONE);
                            rlSyAdd.setVisibility(View.VISIBLE);

                            Drawable leftDrawable1 = getResources().getDrawable(R.mipmap.icon_cysl_sel);
                            Drawable leftDrawable2 = getResources().getDrawable(R.mipmap.icon_ijzs_sel);
                            leftDrawable1.setBounds(0, 0, leftDrawable1.getMinimumWidth(), leftDrawable1.getMinimumHeight());
                            tv1.setCompoundDrawables(leftDrawable1, null, null, null);
                            leftDrawable2.setBounds(0, 0, leftDrawable2.getMinimumWidth(), leftDrawable2.getMinimumHeight());
                            tv2.setCompoundDrawables(leftDrawable2, null, null, null);
                            tvSy1.setVisibility(View.VISIBLE);
                            viewSy1.setVisibility(View.GONE);
                            loadDismiss();
                        }


                    }
                }, 1000);

                break;

            default:
                break;
        }
    }

    @OnClick(R.id.rl_sy_add)
    public void onViewClicked() {
    }
}
